home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-07-13 | 1.6 KB | 55 lines |
- /*
- * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved.
- *
- * Permission to use, copy, modify, and distribute this software
- * and its documentation for NON-COMMERCIAL purposes and without
- * fee is hereby granted provided that this copyright notice
- * appears in all copies. Please refer to the file "copyright.html"
- * for further important copyright and licensing information.
- *
- * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
- * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
- * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
- * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
- * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
- */
- import java.applet.Applet;
- import java.awt.Graphics;
-
- public class Simple extends Applet {
-
- StringBuffer buffer;
-
- public void init() {
- buffer = new StringBuffer();
- addItem("initializing... ");
- }
-
- public void start() {
- addItem("starting... ");
- }
-
- public void stop() {
- addItem("stopping... ");
- }
-
- public void destroy() {
- addItem("preparing for unloading...");
- }
-
- void addItem(String newWord) {
- System.out.println(newWord);
- buffer.append(newWord);
- repaint();
- }
-
- public void paint(Graphics g) {
- //Draw a Rectangle around the applet's display area.
- g.drawRect(0, 0, size().width - 1, size().height - 1);
-
- //Draw the current string inside the rectangle.
- g.drawString(buffer.toString(), 5, 15);
- }
- }
-